
PDF_NAME=index.pdf	# nom du pdf de sortie
SOURCE_NAME=index.tex	# nom du fichier tex principal (qui inclut les autres) sans son extension !
LOG_FILE=index.log		# nom du fichier de log

all: clean $(PDF_NAME)

pdf: $(PDF_NAME)

$(PDF_NAME): $(SOURCE_NAME)
	pdflatex $(SOURCE_NAME)
	latex_count=5 ; \
	while egrep -s 'There were undefined references.' $(LOG_FILE) && [ $$latex_count -gt 0 ] ;\
	    do \
	      echo "Rerunning latex...." ;\
	      pdflatex $(SOURCE_NAME) ;\
	      latex_count=`expr $$latex_count - 1` ;\
	    done


clean:
	rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.glo *.lof $(PDF_NAME)

